package com.kupurui.asteacher.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.android.frame.adapter.CommonAdapter;
import com.android.frame.adapter.ViewHolder;
import com.kupurui.asteacher.R;
import com.kupurui.asteacher.bean.AllJobInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/7/21.
 */

public class AllJobAdapter extends CommonAdapter<AllJobInfo> {

    List<AllJobInfo> list = new ArrayList<>();

    public AllJobAdapter(Context context, List<AllJobInfo> mList, int itemLayoutId) {
        super(context, mList, itemLayoutId);
        this.list = mList;
    }

    @Override
    public void convert(ViewHolder holder, AllJobInfo item, int positon) {
        holder.setTextViewText(R.id.tv_title,item.getTitle());
        holder.setTextViewText(R.id.tv_time,item.getCreat_time());
        TextView tvMonth = holder.getView(R.id.tv_month);
        tvMonth.setText(item.getRiqi());
        TextView tvStatus = holder.getView(R.id.tv_status);
        if (item.getStatus().equals("1")){
            tvStatus.setText("已截止");
            tvStatus.setBackgroundResource(R.drawable.shape_round_gray_90);
        }else if(item.getStatus().equals("2")){
            tvStatus.setText("待批改");
            tvStatus.setBackgroundResource(R.drawable.shape_round_red_90);
        }else if(item.getStatus().equals("3")){
            tvStatus.setText("已评"+item.getShuliang()+"人");
            tvStatus.setBackgroundResource(R.drawable.shape_round_red_90);
        }else if(item.getStatus().equals("4")){
            tvStatus.setText("已完成");
            tvStatus.setBackgroundResource(R.drawable.shape_round_red_90);
        }

        if (positon == 0){
            tvMonth.setVisibility(View.VISIBLE);
        }else{
            if (list.get(positon-1).getRiqi().equals(item.getRiqi())){
                tvMonth.setVisibility(View.GONE);
            }else{
                tvMonth.setVisibility(View.VISIBLE);
            }
        }
        holder.setTextViewText(R.id.tv_submit_num,item.getTijiao()+"/"+item.getTotal()+"人提交");
    }
}
